var uid = 0
export default class Dep{
  constructor() {
    console.log('Dep构造器');
    this.id = uid++
    // watcher的实例
    this.subs = [];
  }
  // 添加订阅
  addSub(sub){
    this.subs.push(sub)
  }
  // 添加依赖
  depend(){
    if(Dep.target){
      this.addSub(Dep.target)
    }
  }
  // 通知更新
  notify(){
    console.log('notify');
    const subs = this.subs.slice()
    subs.forEach(function (item){
     item.update()
    })
  }
}